<?php
/**
 * @package   	JCE
 * @copyright 	Copyright (c) 2009-2012 Ryan Demmer. All rights reserved.
 * @license   	GNU/GPL 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * JCE is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 */
defined('_JEXEC') or die('RESTRICTED');
?>
<form enctype="multipart/form-data" action="index.php" method="post" name="adminForm" id="adminForm" class="form-horizontal">
    <div id="jce">
        <fieldset id="filter-bar" class="btn-toolbar">
            <div class="filter-search btn-group pull-left fltlft">
                <label for="search" class="element-invisible"><?php echo WFText::_('WF_LABEL_SEARCH'); ?></label>
                <input type="text" name="search" id="search" size="30" value="<?php echo $this->lists['search']; ?>" class="text_area" onchange="document.adminForm.submit();" placeholder="" />
            </div>
            <div class="btn-group fltlft">
                <button id="filter_go" onclick="this.form.submit();" class="btn" title="<?php echo WFText::_('WF_LABEL_SEARCH'); ?>"><i class="icon-search"></i>&nbsp;<?php echo WFText::_('WF_LABEL_SEARCH'); ?></button>
                <button id="filter_reset" onclick="document.getElementById('search').value='';this.form.submit();" class="btn" title="<?php echo WFText::_('WF_LABEL_CLEAR'); ?>"><i class="icon-remove"></i>&nbsp;<?php echo WFText::_('WF_LABEL_CLEAR'); ?></button>
            </div>
            <div class="filter-search fltrt btn-group pull-right visible-desktop">
                <div class="upload-container btn-group pull-right">
                    <label for="import" class="element-invisible"><?php echo WFText::_('WF_PROFILES_IMPORT'); ?></label>
                    <div class="input-append upload_button_container">
                        <input type="file" name="import" size="30" id="upload" accept="application/xml" placeholder="<?php echo WFText::_('WF_PROFILES_IMPORT'); ?>" />
                        <button id="upload_button" class="btn upload-import"><i class="icon-arrow-up"></i>&nbsp;<?php echo WFText::_('WF_PROFILES_IMPORT_IMPORT'); ?></button>
                    </div>
                </div>
            </div>
        </fieldset>
        <div class="clr clearfix"></div>
        <table id="profiles-list" class="adminlist table table-striped" style="position: relative;">
            <thead>
                <tr>
                    <th class="hidden-phone"></th>
                    <th>
                        <input type="checkbox" value="" />
                    </th>
                    <th class="title">
                        <?php echo JHTML::_('grid.sort', 'WF_PROFILES_NAME', 'p.name', @$this->lists['order_Dir'], @$this->lists['order']); ?>
                    </th>
                    <th nowrap="nowrap">
                        <?php echo JHTML::_('grid.sort', 'WF_PROFILES_STATE', 'p.published', @$this->lists['order_Dir'], @$this->lists['order']); ?>
                    </th>
                    <th nowrap="nowrap">
                        <?php echo JHTML::_('grid.sort', 'WF_PROFILES_ORDERING', 'p.ordering', @$this->lists['order_Dir'], @$this->lists['order']); ?>
                        <?php
                        if (count($this->rows) > 1) {
                            echo JHTML::_('grid.order', $this->rows);
                        }
                        ?>
                    </th>
                    <th nowrap="nowrap" class="title">
                        <?php echo JHTML::_('grid.sort', 'WF_LABEL_ID', 'p.id', @$this->lists['order_Dir'], @$this->lists['order']); ?>
                    </th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <td colspan="6"><?php echo $this->pagination->getListFooter(); ?></td>
                </tr>
            </tfoot>
            <tbody>
                <?php
                $rows = $this->rows;
                $k = 0;
                for ($i = 0, $n = count($rows); $i < $n; $i++) {
                    $row = $rows[$i];

                    $link = JRoute::_('index.php?option=com_jce&view=profiles&task=edit&cid[]=' . $row->id);

                    // state
                    $state = JHTML::_('grid.published', $row, $i);

                    // checked out
                    $checked = JHTML::_('grid.checkedout', $row, $i);

                    $profile = JTable::getInstance('profiles', 'WFTable');
                    ?>
                    <tr>
                        <td class="order nowrap center hidden-phone">
                            <span class="sortable-handle ui-icon ui-icon-grip-dotted-vertical">
                                <i class="icon-menu"></i>
                            </span>
                        </td>
                        <td align="center">
                            <?php echo $checked; ?>
                        </td>
                        <td>
                            <?php
                            if ($profile->isCheckedOut($this->user->get('id'), $row->checked_out)) {
                                echo $row->name;
                            } else {
                                ?>
                                <span class="editlinktip wf-tooltip" title="<?php echo WFText::_('WF_PROFILES_EDIT'); ?>::<?php echo $row->name; ?>">
                                    <a href="<?php echo $link; ?>">
                                        <?php echo $row->name; ?></a></span>
                            <?php } ?>
                            <p class="smallsub"><?php echo $row->description; ?></p>
                        </td>
                        <td align="center">
                            <?php echo $state; ?>
                        </td>
                        <td class="order" align="center">
                            <span class="order-up">
                                <a title="<?php echo WFText::_('WF_PROFILES_MOVE_UP');?>" href="#" class="btn btn-micro jgrid"><span class="state uparrow"></span><i class="icon-uparrow"></i></a>
                            </span>
                            <span class="order-down">
                                <a title="<?php echo WFText::_('WF_PROFILES_MOVE_DOWN');?>" href="#" class="btn btn-micro jgrid"><span class="state downarrow"></span><i class="icon-downarrow"></i></a>
                            </span>
                            <?php $disabled = $n > 1 ? '' : 'disabled="disabled"'; ?>
                            <input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" <?php echo $disabled ?> class="text_area" style="text-align: center" />
                        </td>
                        <td align="center">
                            <?php echo $row->id; ?>
                        </td>
                    </tr>
                    <?php
                    $k = 1 - $k;
                }
                ?>
            </tbody>
        </table>
    </div>
    <input type="hidden" name="option" value="com_jce" />
    <input type="hidden" name="view" value="profiles" />
    <input type="hidden" name="task" value="" />
    <input type="hidden" name="boxchecked" value="0" />
    <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
    <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
    <?php echo JHTML::_('form.token'); ?>
</form>